home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / pluginy Firefox / 7661 / 7661.xpi / components / RILprefs.js < prev    next >
Text File  |  2009-12-23  |  5KB  |  191 lines

  1. Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
  2.  
  3. function RILprefs() {
  4.     this.wrappedJSObject = this;
  5.     
  6.     this.PREFS = Components.classes["@mozilla.org/preferences-service;1"]
  7.         .getService(Components.interfaces.nsIPrefService).getBranch("isreaditlater.");
  8. }
  9.  
  10. // class definition
  11. RILprefs.prototype = {
  12.  
  13.   // properties required for XPCOM registration:
  14.   classDescription: "Read It Later Prefs Javascript XPCOM Component",
  15.   classID:          Components.ID("{dfad9f70-aaaf-11de-8a39-0800200c9a66}"),
  16.   contractID:       "@ril.ideashower.com/rilprefs;1",
  17.   
  18.   QueryInterface: XPCOMUtils.generateQI(),
  19.  
  20.  
  21.  
  22.     //////////////////////////////////
  23.     // Save prefs
  24.     
  25.     set : function(name, value)
  26.     {
  27.         switch( typeof value )
  28.         {
  29.             case('boolean'):
  30.                 try{
  31.             this.PREFS.setBoolPref(name, value);
  32.             break;
  33.         } catch(e) {
  34.             
  35.             try {
  36.             this.remove(name);
  37.             this.PREFS.setBoolPref(name, value);
  38.             break;
  39.             } catch(e)
  40.             {
  41.             Components.utils.reportError('Error saving pref: '+name+' = '+value);
  42.             Components.utils.reportError(e);
  43.             }
  44.         }
  45.             
  46.             // There are int prefs, but for compatibility reasons, do not use them
  47.             
  48.             default:
  49.                 this.PREFS.setCharPref(name, value);
  50.                 break;
  51.         }    
  52.     },
  53.     
  54.     isSet : function(name)
  55.     {
  56.     return this.PREFS.prefHasUserValue(name);    
  57.     },
  58.     
  59.     setIfDoesNotExist : function(name, value)
  60.     {
  61.     if (!this.isSet(name))
  62.     {
  63.         this.set(name, value);
  64.     }
  65.     
  66.     },
  67.     
  68.     rename : function(oldName, newName) {
  69.         this.set(newName, this.get(oldName));
  70.         this.remove(op);
  71.     },
  72.     
  73.     remove : function(name)
  74.     {
  75.         if (this.isSet(name))
  76.         {
  77.         this.set(name, '');
  78.             return this.PREFS.clearUserPref(name);
  79.         }       
  80.     },
  81.     
  82.     append : function(name, value)
  83.     {
  84.         return this.PREFS.setCharPref(name, this.get(name) + value);    
  85.     },
  86.     
  87.     
  88.     // Get
  89.     
  90.     get : function(name) {
  91.         if (this.isSet(name)) return this.PREFS.getCharPref(name);
  92.     },
  93.     
  94.     getBool : function(name)
  95.     {
  96.         if (this.isSet(name)) {
  97.         try {
  98.         return this.PREFS.getBoolPref(name);
  99.         } catch(e) {
  100.         return this.PREFS.getCharPref(name) == 'true' ? true : false;
  101.         }
  102.         
  103.     }
  104.     },
  105.     
  106.     loadDefaults : function()
  107.     {        
  108.         
  109.         
  110.     //Installation        
  111.     this.setIfDoesNotExist("installed",        (this.isSet('version')) );
  112.     this.setIfDoesNotExist("version",         '');
  113.     this.setIfDoesNotExist("toolbar-btn-added",    false);
  114.     this.setIfDoesNotExist("install-version",    '0');
  115.             
  116.     
  117.     //Reading/Saving
  118.     this.setIfDoesNotExist("read",         'list');
  119.     this.setIfDoesNotExist("mark",         'null');
  120.     this.setIfDoesNotExist("open",         'current');    
  121.     this.setIfDoesNotExist("autoMark",    false);
  122.     this.setIfDoesNotExist("autoCloseTab",    false);
  123.             
  124.     
  125.     //Appearance
  126.     this.setIfDoesNotExist("context-menu",        true);        
  127.     this.setIfDoesNotExist("list-view",        'normal');
  128.     this.setIfDoesNotExist("list-place",        'btn');
  129.     this.setIfDoesNotExist("list-type",        'pages');        
  130.     this.setIfDoesNotExist("list-page",        9);
  131.     this.setIfDoesNotExist("default-sort",             0);        
  132.     this.setIfDoesNotExist("show-count",        false);
  133.     this.setIfDoesNotExist("show-date",        false);
  134.     this.setIfDoesNotExist("force-styles",        true);
  135.     this.setIfDoesNotExist("showStatusIconText",    'item');
  136.     this.setIfDoesNotExist("showStatusIconShare",    'item');
  137.     this.setIfDoesNotExist("showStatusIconClick",    'hide');
  138.     
  139.             
  140.     
  141.     //Keystrokes
  142.     this.setIfDoesNotExist("hotkey_toggle",            'alt||W');
  143.     this.setIfDoesNotExist("hotkey_push",        'alt||P');
  144.     this.setIfDoesNotExist("hotkey_open_list",    'alt||Q');    
  145.     this.setIfDoesNotExist("hotkey_click_mode",    'alt||M');    
  146.     this.setIfDoesNotExist("hotkey_sidebar",    'alt||[');
  147.     this.setIfDoesNotExist("hotkey_gr",        'i');
  148.             
  149.     
  150.     //Syncing
  151.     this.setIfDoesNotExist("since",                '0');
  152.     this.setIfDoesNotExist("autoSync",            true);
  153.         this.setIfDoesNotExist('storeSecurely',         true);
  154.         this.setIfDoesNotExist('promptedAboutMasterPass',false);
  155.         
  156.     
  157.     //Text
  158.     this.setIfDoesNotExist("text-options",     JSON.stringify({
  159.                 L:    0,
  160.                 S:    1,
  161.                 F:    1,
  162.                 M:    1,
  163.                 A:    1
  164.             }));
  165.             
  166.     
  167.     //Google Reader    
  168.     this.setIfDoesNotExist("integrate-gr",    true);
  169.     
  170.             
  171.     
  172.     //Prompt Windows        
  173.     this.setIfDoesNotExist("prompt_clear_offline",true);
  174.     
  175.     
  176.     //Offline
  177.     this.setIfDoesNotExist('getOfflineWeb', true);            
  178.     this.setIfDoesNotExist('getOfflineText', false);
  179.     this.setIfDoesNotExist("autoOffline",    false);
  180.         
  181.     }
  182.   
  183.   
  184.   
  185. };
  186.  
  187. var components = [RILprefs];
  188. function NSGetModule(compMgr, fileSpec) {
  189.   return XPCOMUtils.generateModule(components);
  190. }
  191.